package name.matthewgreet.example8.action; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpSession; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.struts2.ActionSupport; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Actions; import org.apache.struts2.convention.annotation.InterceptorRef; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import name.matthewgreet.example8.dto.PrimeMinisterDTO; import name.matthewgreet.example8.util.PrimeMinisterCompositeCache; import name.matthewgreet.example8.view.PrimeMinisterDisplay; import name.matthewgreet.strutscommons.action.AbstractViewActionSupport; import name.matthewgreet.strutscommons.util.ListCache; import name.matthewgreet.strutscommons.util.NA; /** * Displays search results of board games. */ @InterceptorRef("ViewStack") @Results({ @Result(name=ActionSupport.SUCCESS, location="/pages/PrimeMinisterList.jsp") }) public class ViewPrimeMinisterListAction extends AbstractViewActionSupport { private static final long serialVersionUID = -7979376337555804889L; private Logger LOG = LogManager.getLogger(ViewPrimeMinisterListAction.class); private List<PrimeMinisterDisplay> listDisplay; @Actions({ @Action("/"), @Action("/ViewPrimeMinisterList") }) @Override public String execute() throws Exception { ListCache<NA,Integer,PrimeMinisterDTO> listCache; HttpSession session; List<PrimeMinisterDTO> list; session = getBrowserTabSession(); listCache = PrimeMinisterCompositeCache.getInstance(session).getMasterListCache(); list = listCache.getList(); listDisplay = new ArrayList<>(); for (PrimeMinisterDTO primeMinister: list) { listDisplay.add(new PrimeMinisterDisplay(primeMinister)); } return SUCCESS; } public List<PrimeMinisterDisplay> getListDisplay() { return listDisplay; } }